package com.example.minemodule.model;

import androidx.lifecycle.MutableLiveData;

import com.example.minemodule.entity.BloodBean;
import com.example.minemodule.entity.RecordWeightEntity;
import com.example.minemodule.net.MineApiService;
import com.yilijk.base.base.BaseRepositoryImpl;
import com.yilijk.base.network.RequestParams;
import com.yilijk.base.network.bean.Resource;
import com.yilijk.base.network.core.RetrofitManager;
import com.yilijk.base.network.https.interceptor.NetWorkUtils;
import com.yilijk.base.utils.CommonUtils;

import org.json.JSONObject;

import java.util.HashMap;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2021/11/12
 */
public class RecordModel extends BaseRepositoryImpl {

    /**
     * 保存身高体重
     */

    public MutableLiveData<Resource<RecordWeightEntity.DataBean>> saveHeight(int id, int inquiringPatientId, String height, String weight){
        MutableLiveData<Resource<RecordWeightEntity.DataBean>> liveData = new MutableLiveData<>();
        HashMap params = new HashMap<String,Object>();
        if (id != 0){
            params.put("id",id+"");

        }
        params.put("inquiringPatientId",inquiringPatientId+"");
        params.put("height",height+"");
        params.put("weight",weight+"");
        return observeGo(RetrofitManager.getRetrofitManager().getRetrofit().create(MineApiService.class).getRecordWeightEntity(params), liveData);
    }

    public  MutableLiveData<Resource<BloodBean.DataBean>> saveBloodFat(int inquiringPatientId, String bloodFat, String bloodFatRecordTime, String bloodFatRecordSource){
        MutableLiveData<Resource<BloodBean.DataBean>> liveData = new MutableLiveData<>();
        RequestParams params = new RequestParams();
        params.put("inquiringPatientId",inquiringPatientId);
        params.put("bloodFat",bloodFat);
        params.put("bloodFatRecordTime",bloodFatRecordTime);
        params.put("bloodFatRecordSource",bloodFatRecordSource);
        RequestBody requestBodyToPost = RequestBody.create(MediaType.parse("application/json;charset=UTF-8"), params.toString());
        return observeGo(RetrofitManager.getRetrofitManager().getRetrofit().create(MineApiService.class).getSave(requestBodyToPost), liveData);
    }

}
